<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html>
<head>
	<title></title>
	<base href="<%=basePath%>">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link type="text/css" rel="stylesheet" href="<%=basePath %>jquery-easyui-1.4.2/themes/default/easyui.css">
<link type="text/css" rel="stylesheet" href="<%=basePath %>jquery-easyui-1.4.2/themes/icon.css">
<script type="text/javascript" src="<%=basePath %>js/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="<%=basePath %>jquery-easyui-1.4.2/jquery.easyui.min.js"></script>
<script type="text/javascript" src="<%=basePath %>jquery-easyui-1.4.2/locale/easyui-lang-zh_CN.js"></script>
<style type="text/css">
	.input{
		width: 99%;
		height: 20px;
		margin-top: 10px;
	} 
</style>
<script type="text/javascript">
	function clicklook(){
		$('#win4').window('open');  // open a window   
	}
	$(function(){
		$('#win').window('close');  // close a window  
		$('#win2').window('close');  // close a window  
		$('#win3').window('close');  // close a window  
		$('#win4').window('close');  // close a window  
		$('#dg').datagrid({    
		    url:'<%=basePath %>user/thematic.do',  
		    pagination:true,
		    queryParams:{pageNo:1,pageSize:10, searchthenumber:"", serachthename:""},
		    rownumbers:true,
		    striped:true,
		    frozenColumns:[[{field:'aa',width:50,checkbox:true}]],
		    columns:[[    
		        {field:'theid',title:'主键',width:100 ,hidden:true},//
		        {field:'thenumber',title:'内容',width:400},    
		        {field:'thename',title:'发布时间',width:200},    
		        {field:'thestatus',title:'作者',width:100,align:'left'},  
		        {field:'theremarks',title:'所属知识',width:100,align:'left',
		        	formatter: function(){
						return "<a href='javascript:clicklook();' style='color:blue'>点击查看 </a>";
					}
		        }
		    ]] ,
		    toolbar: "#toolbar"
		}); 
		//下页上一页
		var  page =  $('#dg').datagrid("getPager");
		page.pagination({
			onSelectPage:function(pageNumber, pageSize){
		 		/* $("#dg").pagination('loading');   */
				$("#dg").datagrid('load',{pageNo:pageNumber,pageSize:pageSize, searchthenumber:"", serachthename:""});
				/* $("#dg").pagination('loaded');  */
				page.pagination({
					pageNumber:pageNumber,
					pageSize:pageSize,
					searchthenumber:"",
					serachthename:""
				});
			
			}
		});
	});
	//添加专题
	function saveloadthematic(){
		var thenumber = $("#thenumber").val();
		var thename = $("#thename").val();
		var thestatus = $("#thestatus").val(); 
		var theremarks = $("#theremarks").val(); 
		var theid = $("#theid").val(); 
		$.post("<%=basePath%>user/saveloadthematic.do",{
			"thenumber":thenumber,
			"thename":thename,
			"thestatus":thestatus,
			"theremarks":theremarks,
			"theid":theid
		},function(data){
			//alert(data.result=="OK");
			var msg = "添加专题信息成功！";
			if(theid >0){
				msg="专题修改成功！";
			}
			$.messager.alert('提示信息',msg,'info',function(){
				$('#win').window('close');  // close a window  
				$("#dg").datagrid("reload");
			});
		},"json");
	}
		//添加商品信息
		function  addCart(){
			$('#win').window('open');  // open a window   
			$("#theid").val("");
			}
		
		//编辑商品信息
		function editThematic(){
			//获取表格里面被选中的数据
			var selections = $("#dg").datagrid("getSelections");
			if(selections.length==0){
				$.messager.alert('错误','请选择一行数据进行修改！','error');
				return;
			}
			if (selections.length>1) {
				$.messager.alert('错误','您只能请选择一行数据进行修改！','error');
				return;
			}
			$('#win2').window('open');  // open a window  
			//表单回填
			var theid  = selections[0].theid;
			$.post("<%=basePath%>user/loadThematicTheid.do",{theid:theid},function(data){
				//$('#thename1').val(data.thename);
				$("#form2").form("load",data);
				$("#theid1").val(data.theid);
			},"json");
			}
		//修改专题
		function updateThematicTheid(){
			var thename = $("#thename1").val();
			var thestatus = $("#thestatus1").val(); 
			var theremarks = $("#theremarks1").val(); 
			var theid = $("#theid1").val(); 
			$.post("<%=basePath%>user/updateThematicTheid.do",{
				"thename":thename,
				"thestatus":thestatus,
				"theremarks":theremarks,
				"theid":theid
			},function(data){
				//alert(data.result=="OK");
				var msg = "添加专题信息成功！";
				if(theid > 0){
					msg="专题修改成功！";
				}
				$.messager.alert('提示信息',msg,'info',function(){
					$('#win2').window('close');  // close a window  
					$("#dg").datagrid("reload");
				});
			},"json");
		}
		//删除商品信息
		function deletethematic(){
			$('#win3').window('open');  // open a window   
				}
		
		//确认删除
		function confirmdelete(){
			var selections = $("#dg").datagrid("getSelections");
			var temp =  new Array();
			for(var i = 0;i<selections.length;i++){
				temp.push(selections[i].theid);
			}
			$.post("<%=basePath%>user/deleteThematicTheid.do",{
				"temp":temp
			},function(data){
				if(data.result=="OK"){
					msg="专题删除成功！";
				}
				$.messager.alert('提示信息',msg,'info',function(){
					$('#win3').window('close');  // close a window  
					$("#dg").datagrid("reload");
				});
			},"json");
			
		}
		//搜索商品信息
		function searchthematic(){
			var searchthenumber = $("#searchthenumber").val();
			var serachthename = $("#serachthename").val();
			$("#dg").datagrid('load',{pageNo:1,pageSize:10,searchthenumber:searchthenumber,serachthename:serachthename});
				}
		//查看所有信息
		function searchall(){
			$("#searchthenumber").val("");
			$("#serachthename").val("");
			searchthematic();
				}
		//取消操作
		function cancel(){
			$('#win').window('close');  // close a window  
			$('#win2').window('close');  // close a window  
			$('#win3').window('close');  // close a window  
			$('#win4').window('close');  // close a window  
				}
</script>

</head>
<body class="easyui-layout">
 	<div data-options="region:'center',title:'评论管理'" >
 		<div style="width: 100%;height: 10% " >
 			<div style="padding-top: 1% ;padding-left: 5%">
	 			<label>起始时间：</label>
	 			<input id="dd" type="text" class="easyui-datebox" required="required"></input> 
	 			<label>至</label>
	 			<input id="dd" type="text" class="easyui-datebox" required="required"></input> 
				<input type="text" id="serachthename"   placeholder="名称搜索"/>
				<a id="btn7" href="javascript:searchthematic();" class="easyui-linkbutton" data-options="iconCls:'icon-search'">搜索</a>
				<a id="btn8" href="javascript:searchall();" class="easyui-linkbutton" data-options="iconCls:'icon-search'">查看所有</a>
	 		</div> 
 		</div>
		<table id="dg" style="width: 66%"></table>
		<div id="toolbar" style="float: right;">
 			<a id="btn6" href="javascript:deletethematic();" class="easyui-linkbutton" data-options="iconCls:'icon-delete'">删除</a>
		</div>
	</div>
	<!-- 删除的DIV -->
	<div id="win3" class="easyui-window" title="删除信息" style="width:350px;height:150px"   
        data-options="iconCls:'icon-save',modal:true,collapsible:false,minimizable:false,maximizable:false">   
        <div style="text-align: center; margin-top: 20px">
        	<span>您确认删除这条信息吗？</span><br/><br/><br/>
	        <a id="btn2" href="javascript:confirmdelete();" class="easyui-linkbutton " data-options="iconCls:'icon-add2'">确认</a>  
	        <a id="btn3" href="javascript:cancel();" class="easyui-linkbutton" data-options="iconCls:'icon-undo'">取消</a>
        </div>  
	</div>
	<div id="win4" class="easyui-window" title="查看所属" style="width:350px;height:150px"   
        data-options="iconCls:'icon-save',modal:true,collapsible:false,minimizable:false,maximizable:false">   
        <div style="text-align: center; margin-top: 20px">
        	<span>本知识所属：</span><br/><br/>
	        <a id="btn2" href="javascript:cancel();" class="easyui-linkbutton " data-options="iconCls:'icon-add2'">确认</a>  
        </div>  
	</div>
</body>
</html>